import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/cookie")
public class SetCookieServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //期望通过这个doGet方法,把一个自定义的Cookie数据返回到浏览器这边

        Cookie cookie = new Cookie("date","2023-04-02");
        resp.addCookie(cookie);
        Cookie cookie2 = new Cookie("time","15:18");
        resp.addCookie(cookie2);
        resp.getWriter().write("setCookie ok");

    }
}
